var curry = require('curry');

const OK = "ok";
const ERROR = "error";

// 构建状态
function meta(suc, msg) {
    return {suc, msg};
}

function resp(mt, data, jwt) {
    if (data && jwt) {
        return {mt, data, jwt};
    } else if (data) {
        return {mt, data};
    } else if (mt) {
        return {mt};
    }
}

const success = meta(true, OK);
const succ = () => resp(success);
const succData = (data) => resp(success, data);
const succDataJwt = (data, jwt) => resp(success, data, jwt);

const fail = (msg) => resp(meta(false, msg));

module.exports = {succ, succData, succDataJwt, fail};
